package com.example.hm_dtfkz.ui.adapter;

import android.content.Context;
import android.widget.TextView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.example.hm_dtfkz.R;
import com.example.hm_dtfkz.litepal.AnswerLitePalEntity;

import org.jetbrains.annotations.NotNull;

/**
 * FileName: SwitchAnswerAdapter
 * Author: admin
 * Date: 2022/1/19 16:18
 * Description:
 */
public class SwitchAnswerAdapter extends BaseQuickAdapter<AnswerLitePalEntity, BaseViewHolder> {

    public SwitchAnswerAdapter() {
        super(R.layout.item_switch_answer);
    }

    @Override
    protected void convert(@NotNull BaseViewHolder baseViewHolder, AnswerLitePalEntity litePalEntity) {
        Context context = getContext();
        TextView tvItem = baseViewHolder.getView(R.id.tvItem);
        tvItem.setText(litePalEntity.getTypeName());

        if (litePalEntity.isUnlock()) {
            tvItem.setBackgroundResource(R.drawable.icon_switch_answer_true);
            tvItem.setTextColor(context.getResources().getColor(R.color.Color_C75845));
        } else {
            tvItem.setBackgroundResource(R.drawable.icon_switch_answer_false);
            tvItem.setTextColor(context.getResources().getColor(R.color.Color_FFFFFF));
        }

    }
}
